do while doc_code=doccod .and. .not. eof()
   cont=0
   ppag=pag
   PAG=PAG+1
   if br>66
      if fl>0
         eject
      else
         fl=1
      endif
      cl=50
      hl=hl+1
      @  1, 44 SAY CHR(27)+'G'
      @  1, 44 say 'S. O. S.  M E D I K A'
      @  1, 44 SAY CHR(27)+'H'
      if pag=1
         @  3, 26 SAY 'Schedule of fees of'
         if pract="DENTIST"
            NPOS=DOCW+54
            @ 3, 46 SAY "Drg. "+DOCNAM
         ELSE
            NPOS=DOCW+53
            @ 3, 46 SAY "Dr. "+DOCNAM
         ENDIF
         @  3, NPOS SAY "for the month of "+MON
         @  5,  4 say "Page "+STR(PAG)
         @  5, 64 say "issued on "+dtoc(date())
         BR=8
      else
         @  3, 6 SAY 'Schedule of fees of'
         docw=0
         if pract="DENTIST"
            docw=len(trim(docnam))+6+26
            @ 3, 26 SAY "Drg. "+DOCNAM
         ELSE
            docw=len(trim(docnam))+5+26
            @ 3, 26 SAY "Dr. "+DOCNAM
         ENDIF
         @  3,docw SAY "for the month of "+MON
         cmt=docw+len(MON)+24
         @ 3, cmt say "Continued from page "+ltrim(str(PPAG))
         @ 5,  4 say "Page "+ltrim(STR(PAG))
         @ 5, 64 say "issued on "+dtoc(date())
      endif
      br=8
      @ br,  4 say "INV."
      @ br, 12 say "DATE OF"
      @ br, 30 say "P A T I E N T"
      @ br, 59 say "P R O C E D U R E"
      @ BR, 89 SAY "NBER"
      @ br, 96 say "UNIT"
      @ BR,106 SAY "TOTAL"
      @ br,117 say "GROSS"
      @ BR,127 SAY "TAX"
      @ BR,133 SAY "NET"
      BR=BR+1
      @ BR,  4 SAY "Nber."
      @ BR, 12 SAY "VISIT"
      @ BR, 22 SAY "CODE"
      @ BR, 28 SAY "NAME & FIRST NAME"
      @ BR, 59 SAY "CODE"
      @ BR, 65 SAY "DESCRIPTION"
      @ BR, 96 SAY "PRICE"
      @ BR,106 SAY "PRICE"
      @ BR,118 SAY "FEE"
      @ BR,126 SAY "PPH 21"
      @ BR,133 SAY "FEE"
      IF PAG>1
         BR=BR+2
         ttl1=0
         @ BR,  2 SAY "Carried forward from page"
         @ BR, 28 say ppag  pict "99"
         @ br, 30 say repl(chr(46),99)
         DO SAYG WITH BR,129,TTL,'999,999.99','99,999,999'
*         @ BR,129 say ttl PICT "99,999,999"
      ENDIF
      DO WHILE DOCCOD=DOC_CODE .AND. .NOT. EOF()
         BR=BR+2
         IF BR<58
            TOTPRIC=PUB_PRICE*PROC_X
            IF TOTPRIC=0
               DO CASE
                  CASE AREA_CODE='G' .OR. AREA_CODE='E' .OR. AREA_CODE='P'
                     TAX=DOC_FEE*(100/42.5)*0.06
                  CASE AREA_CODE='D'
                     TAX=DOC_FEE*(100/50)*0.06
                  CASE AREA_CODE='S' .OR. AREA_CODE='O' .OR. AREA_CODE='Y'
                     TAX=DOC_FEE*(100/52)*0.06
               ENDCASE
            ELSE
               IF AREA_CODE='P' .OR. AREA_CODE='E'
                  TAX=DOC_FEE*0.15
               ELSE
                  IF DOC_FEE<TOTPRIC*0.4
                     TAX=DOC_FEE*0.15
                  ELSE
                     TAX=TOTPRIC*0.06
                  ENDIF
               ENDIF
            ENDIF
            if doc_fee>0
               NET=DOC_FEE-TAX
            else
               tax=0
               net=0
            endif
            PROC=PROC+1

            IF AREA_CODE='G' .AND. SUB_AREACO='3'
               @ BR,  0 SAY CHR(27)+'G'+TRANS(PROC,'##9')+CHR(27)+'H'
               @ BR,  4 SAY CHR(27)+'G'+INV_NBER+CHR(27)+'H'
               @ BR, 12 SAY CHR(27)+'G'+DTOC(DATE_VISIT)+CHR(27)+'H'
               @ BR, 22 SAY CHR(27)+'G'+PAT_FILCOD+CHR(27)+'H'
               cPatnam = ALLTRIM(PAT_NAME)+' '+ALLTRIM(PAT_F_NAME)
               @ BR, 30 SAY CHR(27)+'G'+cPatnam+CHR(27)+'H'
               @ BR, 63 SAY CHR(27)+'G'+AREA_CODE+sub_areaco+pro_code+CHR(27)+'H'
*               @ BR, 60 SAY CHR(27)+'G'+SUB_AREACO+CHR(27)+'H'
*               @ BR, 61 SAY CHR(27)+'G'+PRO_CODE+CHR(27)+'H'
               @ BR, 65 SAY CHR(27)+'G'+SHRT_DESCR+CHR(27)+'H'
               @ BR, 89 SAY CHR(27)+'G'+TRANS(PROC_X,'#9')+CHR(27)+'H'
               if area_code='P' .or. area_code='E'
                  @ br, 95 say CHR(27)+'G'+'N / A'+CHR(27)+'H'
                  @ br,105 say CHR(27)+'G'+'N / A'+CHR(27)+'H'
               else
                  IF AEADECI
                     @ BR, 93 SAY CHR(27)+'G'+TRANS(PUB_PRICE,'#,###,##9.99')+CHR(27)+'H'
                     @ BR,103 SAY CHR(27)+'G'+TRANS(TOTPRIC,'#,###,##9.99')+CHR(27)+'H'
                  ELSE
                     @ BR, 93 SAY CHR(27)+'G'+TRANS(PUB_PRICE,'#,###,##9')+CHR(27)+'H'
                     @ BR,103 SAY CHR(27)+'G'+TRANS(TOTPRIC,'#,###,##9')+CHR(27)+'H'
                  ENDIF
               ENDIF
               IF AEADECI
                  @ BR,113 SAY CHR(27)+'G'+TRANS(DOC_FEE,'#,###,##9.99')+CHR(27)+'H'
                  @ BR,123 SAY CHR(27)+'G'+TRANS(TAX,'##,##9.99')+CHR(27)+'H'
                  @ BR,130 SAY CHR(27)+'G'+TRANS(NET,'#,###,##9.99')+CHR(27)+'H'
               ELSE
                  @ BR,113 SAY CHR(27)+'G'+TRANS(DOC_FEE,'#,###,##9')+CHR(27)+'H'
                  @ BR,123 SAY CHR(27)+'G'+TRANS(TAX,'##,##9')+CHR(27)+'H'
                  @ BR,130 SAY CHR(27)+'G'+TRANS(NET,'#,###,##9')+CHR(27)+'H'
               ENDIF
            ELSE
               @ BR,  0 SAY PROC         PICT "999"
               @ BR,  4 SAY INV_NBER
               @ BR, 12 SAY DTOC(DATE_VISIT)
               @ BR, 22 SAY PAT_FILCOD
               @ BR, 30 SAY TRIM(PAT_NAME)+' '+PAT_F_NAME
               @ BR, 59 SAY AREA_CODE+SUB_AREACO+PRO_CODE
               @ BR, 65 SAY SHRT_DESCR
               @ BR, 89 SAY PROC_X      pict "99"
               if area_code='P' .or. area_code='E'
                  @ br, 95 say "N / A"
                  @ br,105 say "N / A"
               else
                  DO SAYG WITH BR,93,PUB_PRICE,'99,999.99','9,999,999'
                  DO SAYG WITH BR,103,TOTPRIC,'99,999.99','9,999,999'
*                  @ BR, 93 SAY PUB_PRICE   pict "9,999,999"
*                  @ BR,103 SAY TOTPRIC     pict "9,999,999"
               ENDIF
               DO SAYG WITH BR,113,DOC_FEE,'99,999.99','9,999,999'
               DO SAYG WITH BR,123,TAX,'999.99','99,999'
               DO SAYG WITH BR,130,NET,'99,999.99','9,999,999'
*               @ BR,113 SAY DOC_FEE     pict "9,999,999"
*               @ BR,123 SAY TAX         pict "99,999"
*               @ BR,130 SAY NET         pict "9,999,999"
            ENDI


            TTL=TTL+NET
            TTL1=TTL1+NET
            TOTGROSS=TOTGROSS+DOC_FEE
            TOTAX=TOTAX+TAX
            TOTGROSSI=TOTGROSSI+DOC_FEE
            TOTAXI=TOTAXI+TAX
            TOTNET=TOTNET+NET
            TOTNETI=TOTNETI+NET
*            PROC=PROC+1
            SKIP
            LOOP
         ELSE
            @ BR,  2 SAY "Total, this page"
            @ br, 19 say repl(chr(46),110)
            DO SAYG WITH BR,130,TTL1,'99,999.99','9,999,999'
*            @ br,130 say ttl1 pict "9,999,999"
            br=br+2
            @ BR,  2 SAY "Total to be carried forward"
            @ br, 30 say repl(chr(46),99)
            DO SAYG WITH BR,129,TTL,'999,999.99','99,999,999'
*           @ br,129 say ttl pict "99,999,999"
            br=100
            cont=1
            exit
         endif
      ENDDO
      if cont=1
         br=100
         loop
      else
         SELE 1
         br=br+2
         if br<56
            @ BR,  2 SAY "Total, this page"
            @ br, 19 say repl(chr(46),110)
            DO SAYG WITH BR,130,TTL1,'99,999.99','9,999,999'
*            @ br,130 say ttl1 pict "9,999,999"
            br=br+2
            @ BR,  2 SAY "Grand Total"
            @ br, 14 say repl(chr(46),115)
            DO SAYG WITH BR,129,TTL,'999,999.99','99,999,999'
*            @ br,129 say ttl pict "99,999,999"
            br=br+2
         else
            @ BR,  2 SAY "Total, this page"
            @ br, 19 say repl(chr(46),110)
            DO SAYG WITH BR,130,TTL1,'99,999.99','9,999,999'
*            @ br,130 say ttl1 pict "9,999,999"
            br=br+2
            @ BR,  2 SAY "Grand Total"
            @ br, 14 say repl(chr(46),115)
            DO SAYG WITH BR,129,TTL,'999,999.99','99,999,999'
*            @ br,129 say ttl pict "99,999,999"
            br=br+2
            br=0
            @  1, 44 SAY CHR(27)+'G'
            @  1, 44 say 'S. O. S.  M E D I K A'
            @  1, 44 SAY CHR(27)+'H'
            @  3, 6 SAY 'Schedule of fees of'
            docw=0
            if pract="DENTIST"
               docw=len(trim(docnam))+6+26
               @ 3, 26 SAY "Drg. "+DOCNAM
            ELSE
               docw=len(trim(docnam))+5+26
               @ 3, 26 SAY "Dr. "+DOCNAM
            ENDIF
            @  3,docw SAY "for the month of "+MON
            cmt=docw+len(MON)+24
            @ 3, cmt say "Continued from page "+ltrim(STR(PPAG))
            @ 5,  4 say "Page "+ltrim(STR(PAG))
            @ 5, 64 say "issued on "+dtoc(date())
            @ 7,  2 SAY "Carried forward from page "
            @ 7, 30 say ppag
            DO SAYG WITH 7,129,TTL,'999,999.99','99,999,999'
*            @ 7,129 say ttl pict "99,999,999"
            br=10
         endif
         @ br, 12 say "TOTAL PAYABLE TO"
         IF PRACT='DENTIST'
            @ BR, 29 SAY "Drg. "+DOCNAM
         ELSE
            @ BR, 29 SAY "Dr. "+DOCNAM
         ENDIF
         DO SAYG WITH BR,44,TTL,'999,999.99','99,999,999'
*         @ BR, 44  SAY TTL PICT "99,999,999"
         @ BR, 55  SAY "Rupiah"
         br=br+2
         @ BR, 12 SAY "For information ==>> Gross :"
         DO SAYG WITH BR,44,TOTGROSSI,'999,999.99','99,999,999'
*         @ BR, 44 say totgrossi pict "99,999,999"
         @ Br, 55 say "Rupiah, less Tax (PPH21) :"
         DO SAYG WITH BR,82,TOTAXI,'99,999.99','9,999,999'
*         @ br, 82 say totaxi pict "9,999,999"
         @ br, 92 say "Rupiah"
         br=br+2
         @ br, 12 say 'N.B. : This total excludes  "On-Duty" fees as well as fees for evacuation and special duties.'
         BR=100
         PAG=0
         EXIT
      endif
   endif
enddo
return
